import service from './ajax/ajaxs.js'
import base from './nozzle/index.js'

// 封装获取验证码的请求函数
export const GetRegisterCode = (parm)=>{
    return service.post(base.getCode,parm)
}
// 封装用户注册账号的请求函数
export const GetRegisterAccount = (parm)=>{
    return service.post(base.getRegister,parm)
}

// 封装用户登录平台的请求函数
export const login = (parm)=>{
    return service.post(base.getLogin,parm)

}

//个人中心
export const UpdateUserDetail = (parm)=>{
    return service.put(base.getUpdateUserDetail,parm)
}
export const GetUserInfo = ()=>{
    return service.get(base.getUserInfo)
}


// 封装获取用户组的请求函数
export const GetUserGroup = (parm)=>{
    return service.get(base.getGroup,{params:parm})
}
// 封装添加用户组的请求函数
export const AddUserGroup = (parm)=>{
    return service.post(base.getGroup,parm)
}
// 封装获取通过关键字进行用户组查询的请求函数
export const GetSearchUserGroup = (parm)=>{
    return service.get(base.getSearchGroup,{params:parm})
}

// 封装修改用户组的请求函数
export const UpdateUserGroup = (parm)=>{
    return service.put(base.getGroup+`${parm.id}/`,parm)
}
// 封装删除用户组的请求函数
export const RemoveUserGroup = (id)=>{
    return service.delete(base.getGroup+`${id}/`)
}

//修改账户信息
export const UpdateUserPassword  = (parm)=>{
    return service.put(base.getUpdateUserPassword,parm)
}
export const GetUserName = ()=>{
    return service.get(base.getUserName)
}



//未激活用户信息
export const GetNotActiveStu = (parm)=>{
    return service.get(base.getNotActiveStu,{params:parm})
}
//激活用户账号
export const ActiveStuAccount  = (parm)=>{
    return service.put(base.getActiveStu,parm)
}
//搜索未激活学生信息,老师信息
export const GetSearchUser = (parm)=>{
    return service.get(base.getSearchUser,{params:parm})
}
//搜索学生信息,type='2'
export const GetSearchStu = (parm)=>{
    return service.get(base.getSearchUser,{params:parm})
}
//获取学生信息
export const GetStu = (parm)=>{
    return service.get(base.getStu,{params:parm})
}
// 封装对于用户(包括老师学生)进行封号处理的请求函数
export const DeactiveUser  = (parm)=>{
    return service.put(base.getDeActiveUser,parm)
}

//封装获取聊天历史消息
export const ViewChatHistory = (roomName, params) => {
    const url = base.getViewChatHistory.replace("{room_name}", roomName);
    return service.get(url, { params });
}


// 封装添加朋友的请求函数
export const AddFriend = (receiverId) => {
    const url = `${base.getAddFriend}${receiverId}/`;
    return service.post(url, { receiver_id: receiverId });
};

// 封装接受好友请求的请求函数
export const AcceptFriendRequest = (requestId) => {
    return service.post(`${base.getAcceptFriendRequest}${requestId}/`);
}
// 封装拒绝好友请求的请求函数
export const RejectFriendRequest = (requestId) => {
    return service.post(`${base.getRejectFriendRequest}${requestId}/`);
}
// 封装删除好友的请求函数
export const DeleteFriend = (friendId) => {
    return service.delete(`${base.getDeleteFriend}${friendId}/`);
}

// 封装添加朋友的请求函数
export const isFriend = (user_id) => {
    const url = `${base.getIsFriend}${user_id}/`;
    return service.get(url);
}

//封装查看用户好友请求状态的接口
export const friendRequestStatus = (user_id) => {
    const url = `${base.getFriendRequestStatus}${user_id}/`;
    return service.get(url);
}

//封装获取好友列表接口
export const getFriends = ()=>{
    return service.get(base.getFriendsList)
}

//封装获取好友申请列表接口
export const friendsRequestList = ()=>{
    return service.get(base.getfriendsRequestList)
}

// 封装删除好友的请求函数
export const getUserDetail = (Id) => {
    return service.get(`${base.getUserDetailByID}${Id}/`);
}